#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
from flask import Flask, url_for

app = Flask(__name__)

with open('public/index.html', mode = 'r', encoding='utf-8') as index:
    index_html = index.read()
@app.route('/')
def load_index():
    return index_html

@app.route('/<filename>')
def load_static(filename):
    with open(filename, mode = 'r', encoding='utf-8') as static_file:
        # 将文件内容以字符串形式加载
        file_content = static_file.read()
    
    return file_content

base_path = 'public/'
for f in os.listdir(base_path):
    url_for('load_static', filename = base_path + f)

if __name__ == '__main__':
    app.run(port = 5000)